/*************************************************************************
	> File Name: P1719.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-04-23 16:46:32
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 150
int g[MAX_N][MAX_N];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> g[i][j];
            g[i][j] += g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1];
        }
    }
    int ans = INT32_MIN;
    for (int x1 = 1; x1 <= n; x1++) {
        for (int y1 = 1; y1 <= n; y1++) {
            for (int x2 = x1 + 1; x2 <= n; x2++) {
                for (int y2 = y1 + 1; y2 <= n; y2++) {
                    int val = g[x2][y2] - g[x1 - 1][y2] - g[x2][y1 - 1] + g[x1- 1][y1 - 1];
                    ans = max(ans, val);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
